//
//  CarShipTaxManager.m
//  EasyToo
//
//  Created by YuanDee on 13-9-23.
//
//

#import "CarShipTaxManager.h"
#import "CarShipTaxRequest.h"
#import "CarShipTaxResponse.h"
#import "ServerCommunicationManager.h"
@implementation CarShipTaxManager

static CarShipTaxManager* manager = nil;


+ (CarShipTaxManager*)shareManager
{
    if (manager == nil) {
        manager = [[CarShipTaxManager alloc] init];
    }
    return manager;
}


- (void)onRequestSuccess:(BaseResponse *)response
{
    if ([response isKindOfClass:[CarShipTaxResponse class]])
    {
        [self handleCarShipTaxOrderSuccess:(CarShipTaxResponse*)response];
    }
    
    
}

- (void)onRequestFail:(BaseResponse *)response
{
    if ([response isKindOfClass:[CarShipTaxResponse class]])
    {
        [self handleCarShipTaxOrderSuccess:(CarShipTaxResponse*)response];
    }
    
}


-(void)orderCarShipTax:(NSString*)license
       andDisplacement:(NSString*)displacement
             andAmount:(NSString*)amount
             andMobile:(NSString*)mobile
{
    CarShipTaxRequest* request = [[CarShipTaxRequest alloc] initWithLicensePlateNumber:license andDisplacement:displacement andAmount:amount andMobile:mobile Delegate:self];
    [[ServerCommunicationManager GetServerCommunication] sendRequest:request];
    
}

- (void)handleCarShipTaxOrderSuccess:(CarShipTaxResponse*)response
{
    NSString *tn = response.tn;
    
    if (tn)
    {
        [self.delegate onOrderCarShipTaxFinish:YES Tn:tn];
    }
    else
    {
        [self.delegate onOrderCarShipTaxFinish:NO Tn:nil];
    }
    
}

@end
